const apiModules = import.meta.glob('./modules/*/*.ts', { eager: true, import: 'default' });

const $api: Recordable = {};

Object.entries(apiModules).forEach(([path, meta]) => {
  const [_, folder, file] = path.replace(/(\.\/|\.ts)/g, '').split('/');

  if (folder === file) {
    $api[folder] = meta;
  } else if ($api[folder]) {
    $api[folder][file] = meta;
  } else {
    $api[folder] = { [file]: meta };
  }
});

export default $api;
